﻿using System;
using System.Linq;

using System.Net.DnsToolkit.Packet;
using System.Net.DnsToolkit.Packet.Records;

namespace System.Net.DnsToolkit.Resolver {
    public class FirstAnswerParser : IAnswerParser {

        public IPAddress Parse(IMessage message) {

            var x = from m in message.Answers
                    where m.RData is IRecordA
                    select m.RData;

            var r = (IRecordA)x.SingleOrDefault();
            
            return r.Address;
        }

    }
}
